from rest_framework import serializers
from .models import ConditionOrder
from django.db import models
from util.const import *
PRICE_TYPE_CHOICE = [0, 1, 2]
COMPARE_TYPE = [0, 1, 2, 3]
ORDER_STATUS_CHOICE = [ORDER_STATUS_RUNNING, ORDER_STATUS_FAILLED, ORDER_STATUS_DONE, ORDER_STATUS_STOPPED]


class ConditionOrderSerializer(serializers.ModelSerializer):
    price_type = models.IntegerField(choices=PRICE_TYPE_CHOICE)
    compare_type = models.IntegerField(choices=COMPARE_TYPE)
    order_status = models.CharField(choices=ORDER_STATUS_CHOICE)

    class Meta:
        model = ConditionOrder
        # 这里定义了返回的字段
        fields = ('order_type', 'side', 'condition_price', 'order_status', 'order_time', 'price_type',
                  'symbol', 'qty', 'compare_type', 'price', 'condition_order_id', 'user_name', 'cookies')


